<template>
  <div>
    <!-- <el-form
      :inline="true"
      :model="dataForm"
      class="dadeFrom"
    >
    <el-input v-model="dataForm.groupName" placeholder="群组名称" style="width: 200px"></el-input>
    <el-input v-model="dataForm.groupNum" placeholder="群组编号" style="width: 200px"></el-input>
    <el-button @click="searchData()" type="primary">查询</el-button>
    <el-button @click="handleReset()" type="primary">重置</el-button>
    </el-form>
    </el-card> -->
    <el-card class="box-card"
             style="margin-top: 10px;">
      <!-- <el-button type="success" size="mini" @click="hanlleAdd()">创建群组</el-button>-->
      <div style="text-align: right;">
        <el-button type="danger"
                   size="mini"
                   @click="$router.go(-1)">返回</el-button>
      </div>
      <el-table :data="dataList"
                border
                style="width: 100%;margin-top: 20px;">
        <el-table-column prop="staffAccount"
                         label="员工账号"
                         align="center">
        </el-table-column>
        <el-table-column prop="staffName"
                         label="员工姓名"
                         align="center">
        </el-table-column>
        <el-table-column prop="createUser"
                         label="创建人Id"
                         align="center">
        </el-table-column>
        <el-table-column label="操作"
                         align="center">
          <template slot-scope="scope">
            <el-button type="danger"
                       size="small"
                       @click="handleDelete(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <Pagination :total="total"
                  :pageNum="pageNum"
                  :pageSize="pageSize"
                  @pageChange="pageChange" />
    </el-card>
  </div>
</template>

<script>
import axios from "axios";
import sendDialog from '../components/sendDialog'
export default {
  data () {
    return {
      dataList: [],
      pageNum: 1,
      pageSize: 10,
      total: 0,
    }
  },
  created () {
    this.handleGroup()
  },
  activated: function () {
  },
  methods: {
    handleDelete (id) {
      let ids = [id]
      this.$confirm(`您确定要删除吗`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: this.$http.adornUrl('staffsysdictdata/delete'),
          method: 'post',
          data: this.$http.adornData(ids, false)
        }).then(({ data }) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.handleGroup()
              }
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      }).catch(() => { })
    },
    handleGroup (sysDictDataId) {
      this.$http({
        url: this.$http.adornUrl('/staffsysdictdata/list'),
        method: 'get',
        params: this.$http.adornParams({
          page: this.pageNum,
          limit: this.pageSize,
          sysDictDataId: this.$route.query.id
        })
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list
          this.total = data.page.totalCount
        }
      })
    },
    // 再次提醒
    // 分页
    pageChange (page) {
      this.pageSize = page._pageSize;
      this.pageNum = page._currentPage;
      this.handleGroup()
    }
  }
};
</script>
<style scoped>
</style>
